//
//  BaseViewController.m
//  VTravel
//
//  Created by lanouhn on 16/8/1.
//  Copyright © 2016年 xiaoYu. All rights reserved.
//

#import "BaseViewController.h"
// 大家可以先了解一下 下周我们要做项目的原型图  https://modao.cc/app/84706c2d3687102e26a146f8d77433af9799acee
@interface BaseViewController ()

@property (nonatomic, strong) MBProgressHUD *HUD;

@end

@implementation BaseViewController

// 懒加载
- (MBProgressHUD *)HUD{
    if (_HUD == nil) {
        self.HUD = [[MBProgressHUD alloc] initWithView:self.view];
        [self.view addSubview:self.HUD];
    }
    return _HUD;
}

/* 显示加载动画 **/
- (void)showHUD{
    [self showHUDWithTitle:nil];
}
/* 隐藏加载动画 **/
- (void)hideHUD{
    if (self.HUD) {
        // 移除并置空
        [self.HUD removeFromSuperview];
        self.HUD = nil;
    }
}
/* 自定义标题加载动画 **/
- (void)showHUDWithTitle:(NSString *)title{
    if (title.length == 0) {
        self.HUD.label.text = nil;
    }else{
        self.HUD.label.text = title;
    }
    // 显示
    [self.HUD showAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.tabBarController.tabBar.tintColor = [UIColor colorWithRed:255.0/255.0 green:124.0/255.0 blue:56.0/255.0 alpha:1];
    
    self.navigationController.navigationBar.backgroundColor = [UIColor colorWithWhite:1 alpha:0];
    
}

#pragma mark ---根据透明度绘制图片
- (UIImage *)drawPngImageWithAlpha:(CGFloat)alpha {
    UIColor *color = [UIColor colorWithRed:1 green:1 blue:1 alpha:alpha];
    //位图大小
    CGSize size = CGSizeMake(1, 1);
    
    //绘制位图
    UIGraphicsBeginImageContext(size);
    
    //获取当前创建的内容
    CGContextRef content = UIGraphicsGetCurrentContext();
    
    //充满指定的填充颜色
    CGContextSetFillColorWithColor(content, color.CGColor);
    
    //指定充满整个矩形
    CGContextFillRect(content, CGRectMake(0, 0, 1, 1));
    
    //绘制image
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    
    //结束绘制
    UIGraphicsEndImageContext();
    
    return image;
}






/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
